<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script>
    var student = {
        "name": "zhangsan",
        "age": 23,
        "isTianLong": true,
        "baba": {"name": "lisi", "age": 19},
        "addr": ["北京", "上海"]
    };
    alert(student.baba.name);   //zhangsan
    //定义JSON字符串
    var jsonStr = '{"name":"zhangsan","age":23,"addr":["北京","上海"]}';
    alert(jsonStr); //{"name":"zhangsan","age":23,"addr":["北京","上海"]}
    //将JSON字符串转为JS对象
    let jsObject = JSON.parse(jsonStr);
    alert(jsObject);    //[object Object]
    alert(jsObject.name);   //zhangsan
    //将JSON字符串转为JS对象
    let jsonStr2 = JSON.stringify(jsObject);
    alert(jsonStr2);    //{"name":"zhangsan","age":23,"addr":["北京","上海"]}
</script>
</body>
</html>